<template>
  <div class="openshop-check">
    <el-form ref="shopCheckForm"
             :model="shopCheckForm"
             :inline="true"
             class="shopCheckForm">
      <el-form-item label="店铺编号/名称"
                    label-width="140px">
        <el-input v-model="shopCheckForm.shopname"></el-input>
      </el-form-item>
      <el-form-item label="行业">
        <el-select v-model="shopCheckForm.industryOne"
                   label-width="80px">
          <el-option label="行业一"
                     value="businessOne"></el-option>
          <el-option label="行业二"
                     value="businessTwo"></el-option>
        </el-select>
        <el-select v-model="shopCheckForm.industryTwo"
                   label-width="80px">
          <el-option label="行业一"
                     value="businessOne"></el-option>
          <el-option label="行业二"
                     value="businessTwo"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="shopCheckFormBtn">
        <el-button type="primary">查询</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
    <div class="shopListTable">
      <el-table :data="tableData">
        <el-table-column prop="shop_id"
                         label="店铺编号"
                         width="120">
        </el-table-column>
        <el-table-column prop="shop_name"
                         label="店铺名称"
                         width="120">
        </el-table-column>
        <el-table-column prop="industry"
                         label="店铺行业"
                         width="120">
        </el-table-column>
        <el-table-column prop="shop_address"
                         label="店铺地址"
                         width="200">
        </el-table-column>
        <el-table-column prop="tel_phone"
                         label="联系电话"
                         width="120">
        </el-table-column>
        <el-table-column prop="shopPromoter"
                         label="推广人ID"
                         width="120">
        </el-table-column>
        <el-table-column prop="checkStatus"
                         label="状态"
                         width="120">
          <template slot-scope="scope">
            <el-tag type="success"
                    v-if="scope.row.checkStatus">待审核</el-tag>
            <el-tag type="danger"
                    v-else>已审核</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="checkRemark"
                         label="备注">
        </el-table-column>
        <el-table-column label="操作"
                         width="300">
          <template slot-scope="scope">
            <span class="handleBtn"
                  @click="$router.push({ name: 'audit', params: { index: scope.$index }})">审核</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { getItem } from '@/utils/storage'
import { getShopList } from '@/api/test.js'
export default {
  name: 'ShopList',
  data () {
    return {
      shopCheckForm: {
        shopname: '',
        industryOne: '',
        industryTwo: ''
      },
      tableData: [],
      storageKey: 'SHOPLIST'
    }
  },
  props: {},
  components: {},
  created () {
    this.loadList()
  },
  mounted () {
  },
  computed: {},
  methods: {
    async loadList () {
      if (getItem(this.storageKey)) {
        const tableData = getItem(this.storageKey)
        this.tableData = tableData
        // this.allindustry = shopList[0].allindustry
        return
      }
      const { data: res } = await getShopList();
      this.tableData = res.data
    }
  }
}
</script>
<style scoped lang="less">
.handleBtn {
  cursor: pointer;
}
.openshop-check {
  padding: 15px;
}
.shopCheckForm {
  border: 1px solid #ccc;
  border-radius: 5px;
  padding-top: 15px;
  .shopCheckFormBtn {
    margin-left: 30px;
  }
}
/deep/.shopListTable {
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  width: 100%;
  tbody {
    td {
      text-align: center;
    }
  }
  thead {
    th {
      text-align: center;
    }
  }
  .handleBtn {
    text-decoration: underline;
    color: blue;
    margin-right: 5px;
  }
}
</style>
